<?php
/*
Plugin Name: Bridge Helper
Plugin URI: http://blog.ljasinski.pl
Description: Resource for bridge (or other card games blog.
Now it only replaces bbo-like notation (!c etc.) with card symbols
Version: 0.1
Author: Łukasz Jasiński
Author URI: http://www.ljasinski.pl
Disclaimer: Use at your own risk. No warranty expressed or implied is provided.
*/
 
add_filter('the_content', 'bridge_helper_card_symbols');
function bridge_helper_card_symbols($text) {
	$needle = Array('!C','!D', '!H', '!S');
	$hay1 = Array('&clubs;', '&diams;', '&hearts;', '&spades;');
	$hay2 = Array(
		'<span style="color: #111111">&clubs;</span>',
		'<span style="color: #FF0000">&diams;</span>',
		'<span style="color: #FF0000">&hearts;</span>',
		'<span style="color: #111111">&spades;</span>'
	);

// TODO: Styling by params
// TODO: CSS
	
	$text = str_ireplace($needle, $hay1, $text);
	$text = str_ireplace($hay1, $hay2, $text);
	
	return $text;
}

add_action('admin_menu', 'bridge_helper_dashboard');

function bridge_helper_dashboard() {
	add_options_page('Bridge Helper by ljasinski.pl', 'Bridge Helper', 'manage_options', 'bridge_helper_dashboard', 'bridge_helper_dashboard_show');
}
// TODO: Board diagram

function bridge_helper_dashboard_show() {
	//TODO: Move dashboard view to new file;
?>
<div class="wrap">
<h2>Bridge Helper</h2>
<p>By <em>Studio Multimedialne ljasinski.pl</em></p>
<hr>
<p>This is very early version (0.1). Just enter into your text !c (case insensitive) to insert &clubs; sign.
Accordingly use !d of &diams;, !h for &hearts; and !s for &spades;.</p>
<h3>ToDo:</h3>
<ul>
	<li>custom symbol styling (by css and dashboard options)</li>
	<li>hand diagrams (PBN parse)</li>
	<li>other - mail me at studio@ljasinski.pl</li>
</ul>
</div>
<?php 
}
?>